package com.sunrise.generico.entidade;

import java.util.Collection;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.validation.Valid;

import lombok.Getter;
import lombok.Setter;

import org.hibernate.validator.constraints.NotEmpty;

import com.sunrise.generico.entidade.iface.EntidadeManter;

@Entity
@Table(name = "usuario")
public class Usuario implements EntidadeManter {

	/**
	 * 
	 */
	private static final long serialVersionUID = 9043724661424862176L;

	@Id
	@SequenceGenerator(name="pk_sequence",sequenceName="usuario_id_seq", allocationSize=1)
	@GeneratedValue(strategy=GenerationType.SEQUENCE,generator="pk_sequence")
	@javax.persistence.Column
	@Getter @Setter
	private Long id;
	
	@NotEmpty( message="{loginObrigatorio}")
	@Column(name = "username", length = 60, nullable = false, unique = true)
	@Getter @Setter
	private String username;
	
	@NotEmpty( message="{passwordObrigatorio}")
	@Column(name = "password", length = 200, nullable = false)
	@Getter @Setter
	private String password;
	
	@NotEmpty( message="{nomeObrigatorio}")
	@Column(name = "nome", length = 100, nullable = false)
	@Getter @Setter
	private String nome;
	
	@NotEmpty( message="{cpfObrigatorio}")
	@Column(name = "cpf", length = 14, nullable = false)
	@Getter @Setter
	private String cpf;

	@NotEmpty( message="{emailObrigatorio}")
	@Column(name = "email", length = 60, unique = true)
	@Getter @Setter
	private String email;
	
	@Column(name = "telefone", length = 20)
	@Getter @Setter
	private String telefone;
	
	@Column(name = "celular", length = 30)
	@Getter @Setter
	private String celular;
	
	@Column(name = "facebookLogin")
	@Getter @Setter
	private String facebookLogin;
	
	@ManyToMany(mappedBy = "usuarios")
	@Getter @Setter
	private Collection<Filial> filais;
	
	@ManyToMany(mappedBy = "usuarios")
	@Getter @Setter
	private Collection<ContaCedente> contasCedente;
	
	@Transient
	@Getter @Setter
	private String primeiroNome;
	
	@Valid
	@ManyToOne
	@Getter @Setter
	private Perfil perfil;
	
	@Transient
	@Getter @Setter
	private String novaSenha;
	
	@Column(name = "ativo")
	@Getter @Setter
	private Boolean ativo;

}
